// 百度坐标转高德（传入经度、纬度）
export function bdDecrypt (bdLng, bdLat) {
  let X_PI = (Math.PI * 3000.0 / 180.0)
  let x = bdLng - 0.0065
  let y = bdLat - 0.006
  let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * X_PI)
  let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * X_PI)
  let ggLng = z * Math.cos(theta)
  let ggLat = z * Math.sin(theta)
  return {lng: ggLng, lat: ggLat}
}

// 高德坐标转百度（传入经度、纬度）
export function bdEncrypt (ggLng, ggLat) {
  let X_PI = (Math.PI * 3000.0 / 180.0)
  let x = ggLng
  let y = ggLat
  let z = Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * X_PI)
  let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * X_PI)
  let bdLng = z * Math.cos(theta) + 0.0065
  let bdLat = z * Math.sin(theta) + 0.006
  return {
    bdLat: bdLng,
    bdLng: bdLat
  }
}
